    //获取cookie
    function getCookie(key) {
        let strCookie = document.cookie;
        let arrCookie = strCookie.split("; ");

        for (let i = 0; i < arrCookie.length; i++) {
            let item = arrCookie[i].split("=");
            if (item[0] == key) {
                return item[1];
            }
        }

        return "";
    }

    //设置cookie
    function setCookie(key, value, day) {
        if (day == undefined) {
            document.cookie = `${key}=${value}`;
        } else {
            let date = new Date();
            date.setDate(date.getDate() + day);
            document.cookie = `${key}=${value};expires=` + date;
        }
    }

    //删除cookie
    function delCookie(key) {
        setCookie(key, '', -1);
    }